package com.example.springboot.view;

import com.example.springboot.entry.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;
import java.util.List;

/**
 * @author by Mr. Li 2021/2/1 10:26
 */
@Controller
public class TableController {
    /*
*       <li><a href="basic_table.html" th:href="@{/basic_table}"> Basic Table</a></li>
        <li><a href="dynamic_table.html" th:href="@{/dynamic_table}"> Advanced Table</a></li>
        <li class="active"><a href="responsive_table.html" th:href="@{/responsive_table}"> Responsive Table</a></li>
        <li><a href="editable_table.html" th:href="@{/editable_table}"> Edit Table</a></li>
    * */

    @GetMapping("/basic_table")
    public String basic_table() {
        return "/tables/basic_table";
    }


    @GetMapping("/dynamic_table")
    public String dynamic_table(Model model) {
        final List<User> users = Arrays.asList(new User("xiaogang", "18"), new User("xiaogang", "18"), new User("xiaogang", "18"),
                new User("xiaogang", "18"),
                new User("xiaogang", "18"));
        model.addAttribute("users", users);
        return "/tables/dynamic_table";
    }

    @GetMapping("/responsive_table")
    public String responsive_table() {
        return "/tables/responsive_table";
    }

    @GetMapping("/editable_table")
    public String editable_table() {
        return "/tables/editable_table";
    }
}
